package tcm.test.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import tcm.test.pojo.entity.Order;

@Mapper
public interface OrderMapper {

    //创建新订单
    @Insert("insert into orders (id, user_id, product_id, quantity, total_amount, status, create_time,update_time) VALUES " +
            "(#{id},#{userId},#{productId},#{quantity},#{totalAmount},#{status},#{createTime},#{updateTime})")
    void register(Order order);

    //获取指定 ID 订单的详情
    @Select("select * from orders where id=#{id}")
    Order getById(Long id);

    //更新指定 ID 订单的详情
    void update(Order order);

    //删除指定id订单
    @Delete("delete from orders where id=#{id}")
    void delete(Long id);
}
